package com.sunrise.xdoc.entity.order;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.sunrise.xdoc.entity.AbstractAuditEntity;
import com.sunrise.xdoc.entity.catalog.SanPham;

@Entity
@Table(name = "order_dinh_muc")
@Inheritance(strategy = InheritanceType.JOINED)
public class DinhMuc extends AbstractAuditEntity {
	private SanPham sanPham;
	private Integer dinhMucBan = 0;
	private Integer conLai = 0;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "san_pham_id")
	@NotNull
	public SanPham getSanPham() {
		return sanPham;
	}

	public void setSanPham(SanPham sanPham) {
		this.sanPham = sanPham;
	}

	@Column(name = "dinh_muc_ban")
	@Max(value = 99999, message = "Định mức bán không được lớn hơn 99.999")
	@Min(value = 0, message = "Đinh mức bán không được nhỏ hơn 0")
	public Integer getDinhMucBan() {
		return dinhMucBan;
	}

	public void setDinhMucBan(Integer dinhMucBan) {
		this.dinhMucBan = dinhMucBan;
	}

	@Column(name = "con_lai")
	@Max(value = 99999, message = "Định mức còn lại không được lớn hơn 99.999")
	public Integer getConLai() {
		return conLai;
	}

	public void setConLai(Integer conLai) {
		this.conLai = conLai;
	}

}
